package top.yinjinbiao.arcface.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.yinjinbiao.arcface.domain.dto.FacePersonDTO;
import top.yinjinbiao.arcface.domain.entity.FacePerson;
import top.yinjinbiao.arcface.domain.query.FacePersonQuery;
import top.yinjinbiao.arcface.mapper.FacePersonMapper;
import top.yinjinbiao.arcface.service.FacePersonService;

import java.util.List;

/**
 * @Description
 * @Author yin.jinbiao
 * @Date 2021/9/27 16:39
 * @Version 1.0
 */
@Service
public class FacePersonServiceImpl extends ServiceImpl<FacePersonMapper,FacePerson> implements FacePersonService {

    @Autowired
    private FacePersonMapper facePersonMapper;

    @Override
    public List list() {
        return facePersonMapper.selectList(null);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int add(FacePerson facePerson) {
        return facePersonMapper.insert(facePerson);
    }

    @Override
    public IPage<FacePersonDTO> page(Page<FacePersonDTO> page, FacePersonQuery query) {
        return facePersonMapper.page(page,query);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int delete(Long id) {
        // TODO 删除文件表中的文件记录
        return facePersonMapper.deleteById(id);
    }
}
